﻿
Imports DAO
Imports DTO

Public Class QuyDinhBUS

    Public Sub ThayDoiQuiDinh(ByVal qd As QuyDinhDTO)
        Dim layQD As New DataTable
        layQD = LayQuiDinh()
        Dim dr As DataRow = layQD.Rows(0)

        If qd.laySoLuongNhapMin = 0 Then
            qd.laySoLuongNhapMin = dr.Item(1)
        End If

        If qd.LaySoLuongTonMin = 0 Then
            qd.LaySoLuongTonMin = dr.Item(2)
        End If

        If qd.LayLuongTonSauKhiBan = 0 Then
            qd.LayLuongTonSauKhiBan = dr.Item(4)
        End If

        If qd.LayNoToiDa = 0 Then
            qd.LayNoToiDa = dr.Item(3)
        End If

        Dim quidinh As New QuyDinhDAO
        quidinh.CapNhatQuyDinh(qd)

    End Sub

    Public Sub ThayDoiMacDinh()
        Dim qui As New QuyDinhDAO
        qui.CapNhatQuyDinhMacDinh()
    End Sub

    Public Function LayQuiDinh() As DataTable
        Dim dt As New DataTable
        Dim qd As New QuyDinhDAO
        dt = qd.LayQuyDinh()
        Return dt
    End Function

End Class
